#include #include #include Adafruit_LSM6DS33 lsm6ds; void setup() { Serial.begin(115200); while (!Serial); if (!lsm6ds.begin_I2C()) { Serial.println("LSM6DS33 not found"); while (1); } Serial.println("LSM6DS33 ready"); } void loop() { sensors_event_t accel; sensors_event_t gyro; sensors_event_t temp; lsm6ds.getEvent(&accel, &gyro, &temp); float ax = accel.acceleration.x; float ay = accel.acceleration.y; float az = accel.acceleration.z; // Calculate roll and pitch float roll = atan2(ay, az) * 180.0 / PI; float pitch = atan2(-ax, sqrt(ay * ay + az * az)) * 180.0 / PI; Serial.print("Roll: "); Serial.print(roll); Serial.print(" Pitch: "); Serial.println(pitch); delay(1500); }